package main

import (
	"net/rpc"
	"os"
	"protection/mysqlA/docs"

	myrpc "github.com/2217263633/kakarpc"
	"github.com/gin-gonic/gin"

	"github.com/wonderivan/logger"
)

var Client *rpc.Client

func main() {
	err := Connect()

	if err != nil {
		logger.Info("connect mysql error", err)
		return
	}

	var yaml myrpc.ServerStruct = myrpc.ServerStruct{
		Chinese_name: "数据库调用",
		Name:         "MysqlService",
		Router: map[string]interface{}{
			"QueryData":  []string{"string", "map"},
			"JudgeTable": []string{"string", "string"},
			"PageSql":    []string{"sql myrpc.SqlStruct", "page int", "size int"},
		},
		Mode:      myrpc.Debug,
		Port:      1237,
		Swag_port: 1238,
	}
	yaml.Path, _ = os.Getwd()

	// 连接注册中心
	// 让注册中心给自己分配一个端口
	docs.SwaggerInfo.BasePath = ""
	rpc := myrpc.RPC{}
	gin.SetMode(gin.ReleaseMode)
	rpc.R = gin.Default()
	rpc.Conn = new(MysqlService)
	myrpc.MyRpc.GoRpc(&yaml, &rpc)

}
